@extends('admin._layouts.default')

@section('main')

      <div class="row-fluid ">
        <div class="span12 box gradient ">
      <div class="title">
            <div class="row-fluid">
                <h3>

                    @if($user->hasAccess('admin'))
                    <select class="inline-block  pull-right " id="section" style="width: 150px;"  >
                        <option value="all">全部</option>
                    </select>
                    <select class="inline-block  pull-right " id="city" style="width: 150px;"   onchange=check(this.value) >
                        <option value="all">全部</option>
                        @foreach($cities as $city)
                            <option value="{{ $city->id }}">{{ $city->name }}</option>
                        @endforeach
                    </select>

                    <a href="javascript:void (0)" onclick="check_mounts()"  class="btn btn-success btn-mini pull-right mg5"><i class="fa fa-edit"></i> 筛选</a>

                    @elseif($user->hasAccess('city'))
                        <select class="inline-block  pull-right " id="section" style="width: 150px;"  >
                            <option value="all">全部</option>
                            @foreach($sections as $section)
                                <option value="{{ $section->id }}">{{ $section->name }}</option>
                            @endforeach
                        </select>

                        <a href="javascript:void (0)" onclick="check_mounts()"  class="btn btn-success btn-mini pull-right mg5"><i class="fa fa-edit"></i> 筛选</a>

                    @endif

                </h3>
            </div>
        </div><!-- End .title -->
        <div class="content min_h500">
          <table id="" class="responsive table table-striped table-bordered" style="width:100%;margin-bottom:0; ">
            <thead>
              <tr>
                 <th class="to_hide_phone">城市</th>
                {{--<th class="ms no_sort" width="140">删除</th>--}}
                 <th class="to_hide_phone">直营商</th>
                {{--<th class="ms no_sort" width="140">删除</th>--}}
                  <th class="to_hide_phone">服务点</th>
                  {{--<th class="ms no_sort" width="140">删除</th>--}}
                  <th class="to_hide_phone">小区</th>
                  {{--<th class="ms no_sort" width="140">删除</th>--}}
              </tr>
            </thead>
            <tbody>
            @foreach($areas as $area)
              <tr>
              <td>{{ $area->fatherinfo->fatherinfo->name }}</td>
              <td>{{ $area->fatherinfo->name }}</td>
              <td>{{ $area->service_address }}</td>
              <td>{{ $area->name }}</td>
              </tr>
              @endforeach

            </tbody>
          </table>

                <div class="row-fluid control-group">

                    <div class="pagination pull-right ">
                      <?php echo $areas->appends(array('city' => $sort_city,'section'=>$sort_section))->links(); ?>
                  </div>
                </div>
                <br/>
        </div><!-- End .content -->
        </div>
        <!-- End box -->
      </div>

@stop


@section('modals')



<div id="water_add" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-sm">
    <div class="modal-content">
      <div class="modal-header">
              <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 class="modal-title" id="myModalLabel">新增本小区水质</h3>
      </div>
      <div class="modal-body">
            {{ Form::open(array('route' => 'admin.areas.store','id'=>'area_form','class'=>'bs-docs-example form-horizontal')) }}
              <input type="hidden" name="area_id" id="delete_id" value="">
              <div class="control-group row-fluid">
                <label class="control-label span4" for="inputPassword">TDS值</label>
                <div class="controls span5 input-append">
                  <input type="text" name="data1" id="inputUsername" class="row-fluid"><span class="add-on"><i class="icon-user"></i></span>
                </div>
              </div>
              <div class="control-group row-fluid">
                <label class="control-label span4" for="inputEmail">TDS值</label>
                <div class="controls span5 input-append">
                  <input type="text" name="data2" id="inputPhone" class="row-fluid"><span class="add-on"><i class="icon-phone"></i></span>
                </div>
              </div>
            </form>


      </div>
      <div class="modal-footer">
                  <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                  <button type="button" onclick="delete_it()" class="btn btn-primary">确定</button>
      </div>
    </div>
  </div>
</div>

<div id="confirm_alert" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-sm">
    <div class="modal-content">
      <div class="modal-header">
              <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 class="modal-title" id="myModalLabel">确定本次操作吗？</h3>
      </div>
      <div class="modal-body">
        <i class=" icon-warning-sign color_red pull-left fs_24"></i>

        <p>一旦【确定】，本次操作不可撤销。</p>

      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
        <button type="button" class="btn btn-primary">确定</button>
      </div>
    </div>
  </div>
</div>
@stop


@section('script')
<script language="javascript" type="text/javascript" src="{{ URL::asset('ad/js/plugins/full-calendar/fullcalendar.min.js') }}"></script>
<script language="javascript" type="text/javascript" src="{{ URL::asset('ad/js/plugins/jquery.peity.min.js') }}"></script>
<script type="text/javascript" language="javascript" src="{{ URL::asset('ad/js/plugins/datatables/js/jquery.dataTables.js') }}"></script>
<script language="javascript" type="text/javascript" src="{{ URL::asset('ad/js/plugins/chosen/chosen/chosen.jquery.min.js') }}"></script>
<script language="javascript" type="text/javascript" src="{{ URL::asset('ad/js/plugins/flot/jquery.flot.js') }}"></script>
<script language="javascript" type="text/javascript" src="{{ URL::asset('ad/js/plugins/jquery.uniform.min.js') }}"></script>
<script src="{{ URL::asset('ad/js/plugins/justGage.1.0.1/resources/js/raphael.2.1.0.min.js') }}"></script>
<script src="{{ URL::asset('ad/js/plugins/justGage.1.0.1/resources/js/justgage.1.0.1.min.js') }}"></script>
<script src="{{ URL::asset('ad/js/scripts.js') }}"></script>


    <script type="text/javascript" charset="utf-8"></script>
    <script>

    function set_delete(id){
        $('#delete_id').val(id);
    }
    function delete_it(){
        $('#area_form').submit();
    }
    function delete_area(id){
        if(confirm('确定要删除小区吗？删除后无法撤销')){
            window.location.href='/admin/areas/delete?id='+id;
        }
    }
    function check_mounts(){
        var city = $('#city').val();
        var section = $('#section').val();
        window.location.href="/admin/areas/wangdian?city="+city+"&section="+section;
    }


    function check(id){
        $.post('{{ route('admin.areas.get_section') }}',{id : id},function(data){
            $('#section').html(data);
        })
    }
    </script>
@stop
